package errno

/**

错误代码说明：
1	                        00	           02
服务级错误（1 为系统级错误）	服务模块代码	   具体错误代码

服务级别错误：
	1 为系统级错误；2 为普通错误，通常是由用户非法操作引起的
服务模块为两位数：
	一个大型系统的服务模块通常不超过两位数，如果超过，说明这个系统该拆分了
错误码为两位数：
	防止一个模块定制过多的错误码，后期不好维护

code = 0 说明是正确返回，code > 0 说明是错误返回

错误通常包括系统级错误码和服务级错误码

建议代码中按服务模块将错误分类

错误码均为 >= 0 的数

HTTP Code 固定为 http.StatusOK，错误码通过 code 来表示。

如果 API 是对外的，错误信息数量有限，则制定错误码非常容易，强烈建议使用错误码。
如果是内部系统，特别是庞大的系统，内部错误会非常多，这时候没必要为每一个错误制定错误码，
而只需为常见的错误制定错误码，对于普通的错误，系统在处理时会统一作为 InternalServerError 处理。

*/

var (
	// Common errors
	OK                  = &Errno{Code: 1, Message: "ok"}
	ErrInternalServer   = &Errno{Code: 10001, Message: "Internal server error."}
	ErrBind             = &Errno{Code: 10002, Message: "参数错误"}
	ErrPermissionDenied = &Errno{Code: 10003, Message: "Permission denied."}
	ErrUserUnlogined    = &Errno{Code: 10004, Message: "user not logged in."}

	// consumer common errors
	ErrValidation     = &Errno{Code: 20001, Message: "Validation failed."}
	ErrDatabase       = &Errno{Code: 20002, Message: "Database error."}
	ErrMissingHeader  = &Errno{Code: 20003, Message: "The length of the `Authorization` header is zero."}
	ErrAuthMissBearer = &Errno{Code: 20004, Message: "The `Authorization` header is miss Bearer."}
	ErrToken          = &Errno{Code: 20005, Message: "Error occurred while signing the JSON web token."}
	ErrTokenExpired   = &Errno{Code: 20005, Message: "Jwt Token Expired"}
	ErrNotReferer     = &Errno{Code: 20006, Message: "Http request not Referer"}
	ErrInvalidDomain  = &Errno{Code: 20007, Message: "Http request invalid domain"}
	ErrRpcPwdNotMatch = &Errno{Code: 20008, Message: "The rpc password not match."}

	// user errors
	ErrEncrypt           = &Errno{Code: 20101, Message: "Error occurred while encrypting the user password."}
	ErrUserNotFound      = &Errno{Code: 20102, Message: "The user was not found."}
	ErrTokenInvalid      = &Errno{Code: 20103, Message: "The token was invalid."}
	ErrPasswordIncorrect = &Errno{Code: 20104, Message: "The password was incorrect."}
	ErrUserNameIncorrect = &Errno{Code: 20104, Message: "The username is null."}
	ErrMissingParameter  = &Errno{Code: 20105, Message: "missing parameter."}
	ErrMissingID         = &Errno{Code: 20106, Message: "missing id."}

	// APP端
	ErrAppIdError = &Errno{Code: 30001, Message: "application's id error."}

	// Ddy
	ErrDeviceNotConnect = &Errno{Code: 4001, Message: "device not connect"}
)
